package com.cmj.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cmj.domain.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * 分类表(Category)表数据库访问层
 *
 * @author makejava
 * @since 2022-03-13 10:49:53
 */
 @Mapper
public interface CategoryMapper extends BaseMapper<Category> {

    /***
     * 根据id查询分类
     * @return 分类表
     */
    @Select("select * from cmj_category where id = #{id} and status = #{status}")
    Category selCategoryList(@Param("id") Long id, @Param("status") int status);

    /***
     * 查询分类类别id
     * @return 返回去重后的id类别
     */
    @Select("select id from cmj_category")
    Set<Long> selCategoryId();

    /***
     * 根据id查询分类名
     * @param categoryId 分类id
     * @return 分类名
     */
    @Select("select name from cmj_category where id = #{categoryId}")
    String selCategoryName(Long categoryId);
}

